﻿@using NetCore.Model
@model List<PageEntity>
@{
    var currentUser = ApplicationEnvironments.DefaultSession.GetUser<UserEntity>();
    string navClass = ViewData["nav-class"].ToString();
}
@{
    foreach (var item in Model)
    {
        bool isRoot = string.IsNullOrWhiteSpace(item.ParentId);
        var childItem = currentUser.MyPageEntities.Where(x => x.ParentId == item.PageId && x.IsDisplay && x.IsMenu).ToList();
        string classActive = isRoot ? Html.IsSelectedArea(item.RouteUrl) : Html.IsSelectedMenu(item.RouteUrl);
        <li class="nav-left-menu-link @classActive " style="border:0;">
            <a href="@(!string.IsNullOrWhiteSpace(item.RouteUrl) ? Url.Content("~/" + item.RouteUrl) : "")">
                <i class="fa @(!string.IsNullOrWhiteSpace(item.Icon) ? item.Icon : "fa-file-o")"></i>
                @if (isRoot)
                {
                    <span class="nav-label">@item.LocalName</span>
                }
                else {
                    @Html.Raw(item.LocalName)
                }
                @if (childItem != null && childItem.Count > 0)
                {
                    <span class="fa arrow"></span>
                }
            </a>
            @if (childItem != null && childItem.Count > 0)
            {
                ViewData["nav-class"] = "nav nav-third-level";
                <ul class="nav   @navClass">
                    <!---nav-second-level collapse-->
                    @await Html.PartialAsync("_ChildNavigation", childItem)

                </ul>
            }
        </li>

    }
}

